import java.util.Scanner;

/**
 * @author gao
 * @date 2025/9/10 10:03
 */

public class Solution {
    public int maxProduct(int[] nums) {
        int n = nums.length, ret = Integer.MIN_VALUE;

        int[] f = new int[n + 1];
        int[] g = new int[n + 1];

        f[0] = g[0] = 1;

        for (int i = 1; i <= n; i++) {
            f[i] = Math.max(nums[i - 1], Math.max(f[i - 1] * nums[i - 1], g[i - 1] * nums[i - 1]));
            ret = Math.max(ret, f[i]);
            g[i] = Math.min(nums[i - 1], Math.min(f[i - 1] * nums[i - 1], g[i - 1] * nums[i - 1]));
        }
        return ret;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            for (int i = 0; i < nums.length; i++) {
                nums[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(solution.maxProduct(nums));
        }
    }
}